<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <!-- 引入react核心库 -->
  <script src="../js/react.development.js"></script>
  <!-- 引入react-dom，用于支持react操作dom -->
  <script src="../js/react-dom.development.js"></script>
  <!-- 引入babel，用于将jsx转为js -->
  <script src="../js/babel.min.js"></script>
  <!-- <script src="https://unpkg.com/react@17/umd/react.development.js"></script> -->
  <!-- <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script> -->

  <!-- Don't use this in production: -->
  <!-- <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> -->

  <style>
    .title {
      background-color: pink;
    }
  </style>
</head>

<body>
  <!-- 准备容器 -->
  <div id="test"></div>


  <script type="text/babel">

    /* 
    jsx语法规则：
      1. 定义虚拟dom时直接在括号内写dom标签
      2. 标签中混入变量时用{}
      3. 样式类名指定用className
      4. 内联样式用{{}}
      5. 只有一个根元素
      6. 标签首字母：为小写时则解析为html同名标签，为大写时react去渲染对应组件
    */
    const myId = "testId"
    const myData = "Hello,React"
    // 1. 创建虚拟dom
    const VDOM = (
      <div>
        <h2 className="title" id={myId}>
          <span style={{ color: 'blue', fontSize: '29px' }}>{myData}</span>
        </h2>
      </div>

    )
    // 2. 渲染虚拟dom到页面
    ReactDOM.render(VDOM, document.getElementById('test'))
  </script>
</body>

</html>